// 订单基础信息
const componentBehaviors = require('../../../../behaviors/component');
import { COMPONENT_OPTIONS } from '../../../../constants/common';
import { TipAlert } from '../../../../common/tip'
const { formatDate } = require('../../../../common/utils');
Component({
    behaviors: [componentBehaviors],
    options: {
        ...COMPONENT_OPTIONS,
    },
    /**
     * 组件的属性列表
     */
    properties: {
        orderInfo: {
            type: Object,
            value: {},
            observer: function (val) {
                val && this.setData({
                    orderTime: formatDate(val.ordered, 'YYYY-MM-DD HH:mm:ss'),
                });
            },
        },
        leftActionText: {
            type: String,
            value: '联系商家',
        },
        rightActionText: {
            type: String,
            value: '联系代言人',
        },
        isHaveRightBtn: {
            type: Boolean,
            value: true,
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        orderTime: '',
    },

    /**
     * 组件的方法列表
     */
    methods: {
        showRemark: function () {
            const { remark } = this.data.orderInfo;
            remark && TipAlert({ title: '备注', message: remark });
        },
        leftAction: function () {
            this.triggerEvent('left');
        },
        rightAction: function () {
            this.triggerEvent('right');
        },
    }
})
